<template>
    <div>
     
                    <input type="text" v-model="query.xm">名称
        
           
                    <input type="text" v-model="query.xb">性别
                    <input type="date" v-model="query.ctime">生日
                    <input type="button" value="查询" @click="xs">

         
        <table>
            <thead>
                <tr>
                    <td>名称</td>
                    <td>性别</td>
                    <td>状态</td>
                    <td>生日</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for="m in data ">
                    <td>{{m.xm}}</td>
                    <td>{{m.xb}}</td>
                    <td>{{m.isdelete}}</td>
                    <td>{{moment(m.ctime).format("yyyy-MM-DD")}}</td>
                    <td>
                    <input type="button" value="删除" @click="sc(m.id)">
                    <input type="button" value="修改" @click="xg(m.id)">
                 

                    </td>
                
                </tr>
            </tbody>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';
import { useRouter } from 'vue-router';
import  Moment  from 'moment';
import moment from 'moment';
var route  = useRouter()

const data=ref([{
    "id": 0,
  "xm": "string",
  "xb": "string",
  "ctime": "2025-03-24T12:31:51.325Z",
  "isdelete": 0
}])

const query=ref({
 
  "xm": "",
  "xb": "",
  "ctime": "",

})

onMounted(()=>{
    xs();
})

const xs=()=>{
    axios.get("https://localhost:7261/api/hy/xs",{params:query.value}).then(res=>{
      data.value=res.data
    })
}
const sc=(a:any)=>{
    if(confirm("确认删除吗"))
    debugger
    axios.get("https://localhost:7261/api/hy/delesc",{params:{id:a}}).then(res=>{
          if(res.data>0){
            alert("删除成功")
            xs();
          }else{
            alert("删除失败")
          }
    })
}
const xg = (did:any)=>{
    route.push({path:"/xg",query:{id:did}});
}
</script>

<style scoped>

</style>